package mediatorPattern;

/**
 * 具体中介类。
 * HouseOwner：房主
 * Tenant： 租房者信息
 */
public class MediatorStructure extends Mediator{

    private HouseOwner houseOwner;
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void constact(String message, Person person) {
        // 因为要相互通信
        if (person instanceof HouseOwner) {
            this.getTenant().getMessage(message);
        } else {
            this.getHouseOwner().getMessage(message);
        }
    }
}
